package com.alex.utils.textsearch.filter;

import com.alex.utils.textsearch.SentenceFilter;

public class RussianTextFilter implements SentenceFilter {

	@Override
	public boolean filter(String sentence) {
		int russianCharCount = 0;
		int totalChars = 0;
		for (int i = 0; i < sentence.length(); i++) {
			char ch = sentence.charAt(i);
			if (!Character.isWhitespace(ch)) {
				if ((ch >= 'а' && ch <= 'я') || (ch >= 'А' && ch <= 'Я')) {
					russianCharCount++;
				}
				totalChars++;
			}
		}
		return ((float) russianCharCount / totalChars) > 0.8f;
	}
}
